script_enemy_main{

let color=rand_int(1,10);

let character="Haruna";
let cutin=character;
let dispelled=0;
let spellcards=1;
let damagerate=10;
let outfit=1;
outfit=(128*outfit)-128;
let usespell=0;
let frame=0; let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshots7=("\script\SoundEffects\shots7.wav");
let SEmagics5=("\script\SoundEffects\magics5.wav");

let GRboss=("\script\Images\CharacterSprites\Haruna.png");

#include_function "script/Functions/HealthBarLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsHaruna1.txt");
	
	LoadSE("\script\SoundEffects\shots7.wav");
	LoadSE("\script\SoundEffects\magics5.wav");

	LoadGraphic("\script\Images\CharacterSprites\Haruna.png");

	SetLife(250);
	SetTimer(35);
	SetInvincibility(120);
	SetDamageRate(10,10); 
	SetEnemyMarker(true);
	MagicCircle(true);
	SetMovePosition02(cx,miny+140,50);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,16);
SetCollisionB(GetX,GetY,16);
SetShotAutoDeleteClip(64,64,64,64);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=4; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

HealthBar();

if(time%200==0 && time>=60){
	if(GetPlayerX>minx+50 && GetPlayerX<maxx-50){
	SetMovePosition01(GetPlayerX+rand(-30,30),rand(miny+120,miny+160),1.5);
	}
	if(GetPlayerX<=minx+50){
	SetMovePosition01(GetPlayerX+rand(15,30),rand(miny+120,miny+160),1.5);
	}
	if(GetPlayerX>=maxx-50){
	SetMovePosition01(GetPlayerX-rand(15,30),rand(miny+120,miny+160),1.5);
	}
}


if(GetCommonData("Difficulty")==1){
	if(time%90==0 && time>=60){
	let angle=GetAngleToPlayer;
	let shot1=0;
	let shot2=1;
		loop(3){
		let delay=0;
		CreateShotA(shot1,GetX,GetY,0);
		SetShotDataA(shot1,0,2,angle,0,0,0,0+color);
			loop(25){
			CreateShotA(shot2,0,0,15);
			SetShotDataA(shot2,0,0,angle+90,0,0.01,1,12+color);
			AddShot(delay,shot1,shot2,0);
			CreateShotA(shot2,0,0,15);
			SetShotDataA(shot2,0,0,angle-90,0,0.01,1,12+color);
			AddShot(delay,shot1,shot2,0);
			delay+=15;
			color+=1;
			if(color>10){ color=1; }
			SetShotDataA(shot1,delay,2,NULL,0,0,0,0+color);
			}
		FireShot(shot1);
		angle+=360/3;
		}
	usespell=40;
	color+=1;
	if(color>10){ color=1; }
	PlaySE(SEshots7);
	}
	if(GetEnemyShotCount>0 && time%15==0){ PlaySE(SEmagics5); }
} //Easy

//=============================================================================================================

if(GetCommonData("Difficulty")==2){
	if(time%90==0 && time>=60){
	let angle=GetAngleToPlayer;
	let shot1=0;
	let shot2=1;
		loop(4){
		let delay=0;
		CreateShotA(shot1,GetX,GetY,0);
		SetShotDataA(shot1,0,2,angle,0,0,0,0+color);
			loop(30){
			CreateShotA(shot2,0,0,15);
			SetShotDataA(shot2,0,0,angle+90,0,0.01,1,12+color);
			AddShot(delay,shot1,shot2,0);
			CreateShotA(shot2,0,0,15);
			SetShotDataA(shot2,0,0,angle-90,0,0.01,1,12+color);
			AddShot(delay,shot1,shot2,0);
			delay+=12;
			color+=1;
			if(color>10){ color=1; }
			SetShotDataA(shot1,delay,2,NULL,0,0,0,0+color);
			}
		FireShot(shot1);
		angle+=360/4;
		}
	usespell=40;
	color+=1;
	if(color>10){ color=1; }
	PlaySE(SEshots7);
	}
	if(GetEnemyShotCount>0 && time%12==0){ PlaySE(SEmagics5); }
} //Normal

//=============================================================================================================

if(GetCommonData("Difficulty")==3){
	if(time%90==0 && time>=60){
	let angle=GetAngleToPlayer;
	let shot1=0;
	let shot2=1;
		loop(5){
		let delay=0;
		CreateShotA(shot1,GetX,GetY,0);
		SetShotDataA(shot1,0,2,angle,0,0,0,0+color);
			loop(30){
			CreateShotA(shot2,0,0,15);
			SetShotDataA(shot2,0,0,angle+90,0,0.01,1,12+color);
			AddShot(delay,shot1,shot2,0);
			CreateShotA(shot2,0,0,15);
			SetShotDataA(shot2,0,0,angle-90,0,0.01,1,12+color);
			AddShot(delay,shot1,shot2,0);
			delay+=10;
			color+=1;
			if(color>10){ color=1; }
			SetShotDataA(shot1,delay,2,NULL,0,0,0,0+color);
			}
		FireShot(shot1);
		angle+=360/5;
		}
	usespell=40;
	color+=1;
	if(color>10){ color=1; }
	PlaySE(SEshots7);
	}
	if(GetEnemyShotCount>0 && time%10==0){ PlaySE(SEmagics5); }
} //Hard

//=============================================================================================================

if(GetCommonData("Difficulty")==4){
	if(time%90==0 && time>=60){
	let angle=GetAngleToPlayer;
	let shot1=0;
	let shot2=1;
		loop(6){
		let delay=0;
		CreateShotA(shot1,GetX,GetY,0);
		SetShotDataA(shot1,0,2,angle,0,0,0,0+color);
			loop(30){
			CreateShotA(shot2,0,0,15);
			SetShotDataA(shot2,0,0,angle+90,0,0.01,1,12+color);
			AddShot(delay,shot1,shot2,0);
			CreateShotA(shot2,0,0,15);
			SetShotDataA(shot2,0,0,angle-90,0,0.01,1,12+color);
			AddShot(delay,shot1,shot2,0);
			delay+=10;
			color+=1;
			if(color>10){ color=1; }
			SetShotDataA(shot1,delay,2,NULL,0,0,0,0+color);
			}
		FireShot(shot1);
		angle+=360/6;
		}
	usespell=40;
	color+=1;
	if(color>10){ color=1; }
	PlaySE(SEshots7);
	}
	if(GetEnemyShotCount>0 && time%10==0){ PlaySE(SEmagics5); }
} //Lunatic


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }
SetCommonData("Boss1X",GetX); SetCommonData("Boss1Y",GetY);

#include_function "script/Functions/HealthBar.txt";
}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }

	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	if(GetLife>0){ DrawGraphic(GetX,GetY); }
}
 
@Finalize{
}

}